package cn.zxcoder.config;


import cn.zxcoder.entity.Res;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class MyException {

    @ExceptionHandler(ArithmeticException.class)
    public Res exceptionHander() {
        log.error("出现了算术异常");
        return new Res(false, null, "出现了算术异常");
    }

    @ExceptionHandler(IncepterException.class)
    public Res incepterExceptionHander() {
        log.error("出现了拦截器异常");
        return new Res(false, null, "出现了了拦截器异常");
    }

//    @ExceptionHandler(NullPointerException.class)
//    public Res NullExceptionHander() {
//        log.error("出现了空指针异常");
//        return new Res(false, null, "出现了了空指针异常");
//    }
}
